# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=pandocfilters
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}"  "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.4.2
pkgrel=1
pkgdesc="A python module for writing pandoc filters (mingw-w64)"
arch=('any')
url='https://pypi.python.org/pypi/pandocfilters'
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("${_realname}-${pkgver}.tar.gz::https://pypi.io/packages/source/p/pandocfilters/pandocfilters-${pkgver}.tar.gz")
sha256sums=('b3dd70e169bb5449e6bc6ff96aea89c5eea8c5f6ab5e207fc2f521a2cf4a0da9')

prepare() {
  cd "$srcdir"/

  for pver in {2,3}; do
    rm -rf python${pver}-build-${CARCH} | true
    cp -r "${_realname}-${pkgver}" "python${pver}-build-${CARCH}"
  done
}

build() {
  for pver in {2,3}; do
    msg "Python ${pver} build for ${CARCH}"
    cd "${srcdir}/python${pver}-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python${pver} setup.py build
  done
}

#check() {
#  for pver in {2,3}; do
#    msg "Python ${pver} test for ${CARCH}"
#    cd "${srcdir}/python${pver}-build-${CARCH}"
#    ${MINGW_PREFIX}/bin/python${pver} setup.py check
#  done
#}

package_python3-pandocfilters() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}

package_python2-pandocfilters() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}

package_mingw-w64-i686-python2-pandocfilters() {
  package_python2-pandocfilters
}

package_mingw-w64-i686-python3-pandocfilters() {
  package_python3-pandocfilters
}

package_mingw-w64-x86_64-python2-pandocfilters() {
  package_python2-pandocfilters
}

package_mingw-w64-x86_64-python3-pandocfilters() {
  package_python3-pandocfilters
}
